package com.yowasa.xiuxian.engine.battle.strategy.skill.wood;

import com.yowasa.xiuxian.annoations.BS;
import com.yowasa.xiuxian.constant.XiuxianConstants;
import com.yowasa.xiuxian.engine.battle.strategy.BaseDefendStrategy;
import com.yowasa.xiuxian.engine.battle.strategy.BattleStrategy;
import com.yowasa.xiuxian.entity.bo.battle.BattleContent;
import com.yowasa.xiuxian.entity.bo.battle.TempUserBattle;
import com.yowasa.xiuxian.entity.bo.battle.UserBattleContent;
import com.yowasa.xiuxian.entity.bo.user.UserBO;
import com.yowasa.xiuxian.entity.enums.ElementEnum;
import com.yowasa.xiuxian.entity.enums.StageEnum;
import com.yowasa.xiuxian.exception.HandlerException;
import org.springframework.core.annotation.Order;

@BS(name = "互济诀", upAbility = 4, needTravel = 1000)
@Order(3)
public class HuJiJue extends BaseDefendStrategy {
    @Override
    public ElementEnum getElement() {
        return ElementEnum.WOOD;
    }

    @Override
    public void limit(UserBO user) {
        if (user.getElement().get("木") < XiuxianConstants.DEFAULT_ELEMENT_ACTIVITY) {
            throw new HandlerException("学习/使用互济诀必须具有木灵根");
        }
        if (user.getStage() < StageEnum.ZHU_JI.getLevel()) {
            throw new HandlerException("学习/使用互济诀至少要始明之青");
        }
    }
    @Override
    public String limitDesc() {
        return "达到始明之青且具有木灵根";
    }

    @Override
    public String desc() {
        return "依据受到的伤害提高自己的治疗效率(失去当前血量的百分之多少就提高该比率的治疗效率),并回复该伤害50%的mp";
    }

    @Override
    public int defend(UserBattleContent user, UserBattleContent battleUser, BattleStrategy bs, int dmg, BattleContent content) {
        TempUserBattle tempBattleInfo = user.getTempBattleInfo();
        user.getBattleInfo().setCmp(user.getBattleInfo().getCmp() + dmg / 2);
        int up = 100 * dmg / user.getBattleInfo().getChp();
        tempBattleInfo.setRestoreRate(tempBattleInfo.getRestoreRate() + up);
        return dmg;
    }


    @Override
    public boolean check(UserBattleContent user, BattleStrategy bs, BattleContent content) {
        return true;
    }

}
